<template>
  <page-body>
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center selectfriends_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub selectfriends_fd0_0'>
          <view class='flex flex-wrap align-center selectfriends_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  selectfriends_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='selectfriends_fd0_0_c1_c0'>选择好友</text>
          </view>
          <view class='flex flex-wrap align-center justify-end selectfriends_fd0_0_c0'>
            <text class='selectfriends_fd0_0_c2_c0' @click="submit">确定</text>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex align-center justify-between benben-flex-layout selectfriends_flex_1">
        <view class='flex flex-wrap align-center selectfriends_fd1_0'>
          <image class='selectfriends_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"192.png"'></image>
          <benben-input type="text" :placeholder="`输入好友昵称`" v-model="name" confirm-type="done" :maxlength="-1"
            :adjust-position='true' placeholder-style="color:#999;font-size:28rpx" />
        </view>
        <text @click.stop="getListFunc">搜索</text>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction align-stretch benben-flex-layout">
        <view class='flex flex-wrap align-center justify-between selectfriends_fd2_0' v-for="(item,index) in dataList"
          :key="index">
          <view class='flex flex-wrap align-center'>
            <image class='selectfriends_fd2_0_c0_c0' mode="aspectFill" :src='item.avatar'></image>
            <text class='selectfriends_fd2_0_c0_c1'>{{item.nickname}}</text>
          </view>
          <view class='flex flex-wrap align-center' @click="choose(item)">
            <image class='selectfriends_fd2_0_c1_c0' mode="aspectFit" v-if="item.check" :src='STATIC_URL+"166.png"'>
            </image>
            <image class='selectfriends_fd2_0_c1_c1' mode="aspectFit" v-else :src='STATIC_URL+"193.png"'></image>
          </view>
        </view>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </page-body>
</template>
<script>
  export default {
    components: {},

    data() {
      return {
        "name": "",
        "id": "",
        dataList: [],
        specifyuserid: ''
      };
    },
    computed: {

    },
    watch: {},
    onLoad(options) {
      let {
        id,
        specifyuserid
      } = options
      if (id !== undefined) this.id = id
      if (specifyuserid !== undefined) this.specifyuserid = specifyuserid
      this.getListFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      choose(item) {
        item.check = !item.check
      },
      submit() {
        let checkList = this.dataList.filter(item => {
          return item.check
        })
        let ids = checkList.map(item => {
          return item.fans_id
        })
        uni.$emit('specifyuser', ids)
        uni.navigateBack()
      },
      getListFunc() {
        this.$api.post(global.apiUrls.post669b86535dab5, {
          name: this.name,
          specifyuserid: this.specifyuserid
        }).then(res => {
          if (res.data.code == 1) {
            this.dataList = res.data.data
          }
        })
      },
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: var(--benbenbgColor1);
    background-size: 100% auto;
  }

  .selectfriends_flex_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .selectfriends_fd0_0_c2_c0 {
    color: rgba(23, 107, 232, 1);
  }

  .selectfriends_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .selectfriends_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .selectfriends_fd0_0_c0 {
    width: 120rpx;
  }

  .selectfriends_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .selectfriends_flex_1 {
    background: var(--benbenbgColor1);
    padding: 24rpx;
    background-size: 100% auto;
  }

  .selectfriends_fd1_0_c0 {
    width: 24rpx;
    height: 24rpx;
    margin: 0rpx 16rpx 0rpx 0rpx;
  }

  .selectfriends_fd1_0 {
    background: #F8F8F8;
    border-radius: 34rpx;
    width: 600rpx;
    height: 64rpx;
    line-height: 64rpx;
    padding: 0rpx 24rpx 0rpx 24rpx;
  }

  .selectfriends_fd2_0_c1_c1 {
    width: 36rpx;
    height: 36rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .selectfriends_fd2_0_c1_c0 {
    width: 36rpx;
    height: 36rpx;
  }

  .selectfriends_fd2_0_c0_c1 {
    margin: 0rpx 32rpx 0rpx 32rpx;
    max-width: 350rpx;
    -webkit-line-clamp: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
  }

  .selectfriends_fd2_0_c0_c0 {
    width: 56rpx;
    height: 56rpx;
    border-radius: 100rpx;
  }

  .selectfriends_fd2_0 {
    background: var(--benbenbgColor1);
    background-size: 100% auto;
    width: 100%;
    padding: 24rpx;
  }
</style>
